package cn.lifei.auth.service.impl;

import cn.lifei.auth.domain.Role;
import cn.lifei.auth.dto.RolePermissionDTO;
import cn.lifei.auth.mapper.RoleMapper;
import cn.lifei.auth.service.IRoleService;
import cn.lifei.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lifei
 * @since 2023-12-03
 */
@Service
public class RoleServiceImpl extends BaseServiceImpl<Role> implements IRoleService {

    @Autowired
    private RoleMapper roleMapper;


    @Override
    public void saveAuth(RolePermissionDTO dto) {
        roleMapper.deleteAuth(dto.getId());
        if (dto.getPermissions().size() != 0){
            roleMapper.saveAuth(dto);

        }
    }

    @Override
    public List<Long> queryPermissionById(Long id) {

        return roleMapper.queryPermissionById(id);

    }
}
